package czolgisci.tiles;

import java.awt.Point;
import java.io.IOException;
import utils.geom.Direction;

/**
 * klasa definująca czołg, dziedziczy po AMovableTile (i tam należy szukać opisu
 * standardowych metod)
 * 
 * @author kasztan
 * @version 1.0
 */
public class Tank extends AMovableTile
{
	private boolean destroyed;

	public Tank(String imagePath, Point position) throws IOException
	{
		super(imagePath, position);
		xSpeed = 7;
		ySpeed = 7;
		destroyed = false;
	}

	@Override
	public void moveEast()
	{
		if(destroyed) return;
		setDirection(Direction.EAST);
		position.x += xSpeed;
		feedbackListener.onTankMove(this);
	}

	@Override
	public void moveNorth()
	{
		if(destroyed) return;
		setDirection(Direction.NORTH);
		position.y -= ySpeed;
		feedbackListener.onTankMove(this);
	}

	@Override
	public void moveSouth()
	{
		if(destroyed) return;
		setDirection(Direction.SOUTH);
		position.y += ySpeed;
		feedbackListener.onTankMove(this);
	}

	@Override
	public void moveWest()
	{
		if(destroyed) return;
		setDirection(Direction.WEST);
		position.x -= xSpeed;
		feedbackListener.onTankMove(this);
	}

	/**
	 * strzał czołgu
	 */
	public void shoot()
	{
		feedbackListener.onShoot(this);
	}

	/**
	 * metoda powodująca eksplozję czołgu
	 */
	public void explode()
	{
		// TODO eksplozja
	}
	
	public void destroy()
	{
		destroyed = true;
	}
	public boolean isDestroyed()
	{
		return destroyed;
	}
	public void raise()
	{
		destroyed = false;
	}
}
